package znbkBkfx.BKFX_PPT;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.znbk.znbklibrary.base.AnswerViewPagerAdapter;
import com.example.znbk.znbklibrary.base.BaseFragment;
import com.example.znbk.znbklibrary.dialog.ButtomResultAnswerSheetDialog;
import com.lancoo.znbkxx.R;
import com.tt.CoreType;
import com.tt.QType;
import com.tt.SkEgnManager;
import com.tt.listener.OnRecordListener;
import com.tt.widget.AudioRecoderUtils;
import com.tt.widget.JSONTool;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import znbkBkfx.BkfxActivity;
import znbkBkfx.GetBkfxJson.BkfxPaperEntity;

@SuppressLint("ValidFragment")
public class BkfxPptFragment extends BaseFragment {

    private BkfxPaperEntity bkfxPaperEntity;
    private int childIndex = -1;
    private CallBackFragmentPpt callBackFragmentPpt;
    public BkfxPptFragment(BkfxPaperEntity bkfxPaperEntity, int childIndex, CallBackFragmentPpt callBackFragmentPpt){
        this.bkfxPaperEntity = bkfxPaperEntity;
        this.childIndex = childIndex;
        this.callBackFragmentPpt = callBackFragmentPpt;
    }

    @Override
    protected int createLayout() {
        return R.layout.bkfx_fragment_ppt;
    }

    String FunctionXY = "<html>\n" +
            "    <head>\n" +
            "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" +
            "        <script type=\"text/javascript\">\n" +
            "\n" +
            "             function scrollTop(id){\n" +
            "                var input = document.getElementById(id); // 根据ID取得元素对象\n" +
            "                var sizeObj = input.getBoundingClientRect(); // 取得元素距离窗口的绝对位置\n" +
            "                var inputOffsetTop = sizeObj.top + bodyOffset.top; // 距顶部\n" +
            "                return inputOffsetTop;\n" +
            "             }\n" +
            "\n" +
            "             function slideTo (targetPageY) {\n" +
            "              var timer = setInterval(function () {\n" +
            "                  var currentY = document.documentElement.scrollTop || document.body.scrollTop;//当前及滑动中任意时刻位置\n" +
            "                  var distance = targetPageY > currentY ? targetPageY - currentY : currentY - targetPageY;//剩余距离\n" +
            "                  var speed = Math.ceil(distance/10);//每时刻速度\n" +
            "                  if (currentY == targetPageY) {\n" +
            "                   clearInterval(timer);\n" +
            "                  } else {\n" +
            "                   window.scrollTo(0,targetPageY > currentY ? currentY + speed : currentY - speed);\n" +
            "                  }\n" +
            "                 },10);\n" +
            "             }\n" +
            "        </script>\n" +
            "    </head>\n" +
            "</html>";
    String Function = "<html>\n" +
            "<head>\n" +
            "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" +
            "    <script type=\"text/javascript\">\n" +
            "\t  function CalledByJavaCodeWithPara(id,arg) {\n" +
            "\t       document.getElementById(id,).innerHTML = arg;\n" +
            "      }\n" +
            "    </script>\n" +
            "</head>\n" +
            "</html>";
    String Function_backgroundColor = "<html>\n" +
            "<head>\n" +
            "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" +
            "    <script type=\"text/javascript\">\n" +
            "\t  function setBackGroundColor(id,bgColor) {\n" +
            "\t       document.getElementById(id,).style.backgroundColor = bgColor;\n" +
            "      }\n" +
            "    </script>\n" +
            "</head>\n" +
            "</html>";

    private WebView mWvQuesBody;
    private RelativeLayout mRlMyRecordBg;
    private ImageView mIvMyRecordMi;
    private Drawable drawableMi;
    private TextView mTvHintAnswerType;

    private ViewPager mVpAnswer;
    public AnswerViewPagerAdapter mAnswerViewPagerAdapter;
    private ArrayList<View> list;

    private LinearLayout mLlResultStuScore;
    @SuppressLint("NewApi")
    @Override
    protected void initView(View view) {

        clickWhichIndex = bkfxPaperEntity.getQuesList().get(childIndex).
                getChildList().get(0).getSubChildList().get(0).getSubChildItem().get(0).getSortIndex();

        mWvQuesBody = view.findViewById(R.id.wv_quesBody);
        mWvQuesBody.setBackgroundColor(0); // 设置背景色
        mWvQuesBody.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        // 启用javascript
        mWvQuesBody.getSettings().setJavaScriptEnabled(true);
        mWvQuesBody.setWebViewClient(new WebViewClient());
        mWvQuesBody.setWebChromeClient(new WebChromeClient());

        String QuesBody = bkfxPaperEntity.getQuesList().get(childIndex).getChildList().get(0).getSubChildList().get(0).getSubChildAsk();
        QuesBody = QuesBody.replaceAll("clickFunction","Android.clickFunction");
        mWvQuesBody.loadData(FunctionXY+Function+Function_backgroundColor+QuesBody,"text/html","utf-8");
        mWvQuesBody.addJavascriptInterface(new JSInterface(), "Android");

        //显示Answer信息
        mVpAnswer = view.findViewById(R.id.vp_answerPpt);
        list = new ArrayList<>();
        list.clear();
        RecyclerView mRvAnswer = new RecyclerView(getActivity());
        mRvAnswer.setLayoutManager(new LinearLayoutManager(getActivity()));//必须先设置LayoutManager
        BkfxPptAnswerAdapter mAnswerAdapter = new BkfxPptAnswerAdapter(getActivity(),
                bkfxPaperEntity,childIndex,new BkfxPptAnswerAdapter.CallBackAdapterPpt() {
            @Override
            public void callHideRecordMiView() {
                    hideRecordMiView();
            }

            @Override
            public void callClickWhichIndex(String stuAnswer) {
                //选择答案后刷新界面显示
                Log.e("mTvOptionContentA", "===========callClickWhichIndex===================" + clickWhichIndex);
                int SortIndexFirst = bkfxPaperEntity.getQuesList().get(childIndex).getChildList().
                        get(0).getSubChildList().get(0).getSubChildItem().get(0).getSortIndex();
                Log.e("mTvOptionContent", "===========SortIndex===================" + SortIndexFirst);
                bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                        get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex - SortIndexFirst).setStuAnswer(stuAnswer);

                int SubmitState = bkfxPaperEntity.getPaperAnswer().get(childIndex).getSubmitState();
                int SubChildItemSize = bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().get(0).
                        getSubChildList().get(0).getSubChildItem().size();
                for(int j=0;j<SubChildItemSize;j++) {

                    String StuAnswer = bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(j).getStuAnswer();
                    String ItemAnswer = bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(j).getItemAnswer();
                    int SortIndex = bkfxPaperEntity.getQuesList().get(childIndex).getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(j).getSortIndex();

                    if(clickWhichIndex==SortIndex) {

                        if(SubmitState==2){

                        }else {
                            mWvQuesBody.loadUrl("javascript:setBackGroundColor('" + "blank" + clickWhichIndex +
                                    "','" + "#326DE9" + "')");
                            if (StuAnswer.equals("")) {
                                mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + (clickWhichIndex) +
                                        "','" + "<font color=\"#ffffff\">" + (clickWhichIndex) + "</font>')");
                            } else {
                                mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + (clickWhichIndex) +
                                        "','" + "<font color=\"#ffffff\">" + (clickWhichIndex) + "." + StuAnswer + "</font>')");
                            }
                        }
                    }else{

                        if(SubmitState==2){

                        }else {
                            mWvQuesBody.loadUrl("javascript:setBackGroundColor('" + "blank" + SortIndex +
                                    "','" + "#00000000" + "')");
                            if (StuAnswer.equals("")) {
                                mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex +
                                        "','" + "<font color=\"#326DE9\">" + SortIndex + "</font>')");
                            } else {
                                mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex +
                                        "','" + "<font color=\"#326DE9\">" + SortIndex + "." + StuAnswer + "</font>')");
                            }
                        }
                    }
                }

            }

            @Override
            public void callShowResultStuScore(double stuScore) {
                refreshRecordAnswer();
//                showResultStuScore(stuScore);
            }

            @Override
            public void callSetCurrentStuAnswer(String currentStuAnswer) {
                int SortIndexFirst = bkfxPaperEntity.getQuesList().get(childIndex).
                        getChildList().get(0).getSubChildList().get(0).getSubChildItem().get(0).getSortIndex();
                bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().get(0).
                        getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer(currentStuAnswer);
            }

        });
        mAnswerAdapter.setHasStableIds(true);
        mRvAnswer.setAdapter(mAnswerAdapter);
        int ItemSize  = bkfxPaperEntity.getQuesList().get(childIndex).getTotalItemCount();
        mRvAnswer.setItemViewCacheSize(ItemSize);
        list.add(mRvAnswer);
        mAnswerViewPagerAdapter = new AnswerViewPagerAdapter(list);
        mVpAnswer.setAdapter(mAnswerViewPagerAdapter);
//        bkfxPaperEntity.getPaperAnswer().get(childIndex).setCurrentSubChildAnswerIndex(0);
        mVpAnswer.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {

            }

            @Override
            public void onPageSelected(int i) {
//                bkfxPaperEntity.getPaperAnswer().get(childIndex).setCurrentSubChildAnswerIndex(i);

            }

            @Override
            public void onPageScrollStateChanged(int i) {

            }
        });

        //显示话咪
        mRlMyRecordBg = view.findViewById(R.id.rl_myRecordBg);
        mRlMyRecordBg.setVisibility(View.GONE);
        mRlMyRecordBg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                return;
            }
        });
        mIvMyRecordMi = view.findViewById(R.id.iv_myRecordMi);
        drawableMi = mIvMyRecordMi.getDrawable();

        mTvHintAnswerType = view.findViewById(R.id.tv_hintAnswerType);
        ObjectAnimator objectAnimator = ObjectAnimator.ofInt(mTvHintAnswerType,"textColor",0xffffffff,0xffff00aa);
        objectAnimator.setDuration(2000);
        objectAnimator.setRepeatCount(Animation.INFINITE);
        objectAnimator.setRepeatMode(ValueAnimator.REVERSE);
        objectAnimator.start();

        //学生作答得分
        mLlResultStuScore = view.findViewById(R.id.ll_resultStuScore);

        /****************************************************************************************/
        final Handler mH1 = new Handler();
        mH1.postDelayed(new Runnable() {
            @SuppressLint("NewApi")
            @Override
            public void run() {

                    int SortIndex = bkfxPaperEntity.getQuesList().get(childIndex).
                            getChildList().get(0).getSubChildList().get(0).getSubChildItem().get(0).getSortIndex();
                    Log.e("callClickWhichIndexAAA", "====11111=======onReceiveValue value=============" + SortIndex);

                    mWvQuesBody.evaluateJavascript("javascript:scrollTop('"+"blank"+SortIndex+"')", new ValueCallback<String>() {

                        @Override
                        public void onReceiveValue(String value) {
                            int SubmitState = bkfxPaperEntity.getPaperAnswer().get(childIndex).getSubmitState();

                            int SubChildItemSize = bkfxPaperEntity.getQuesList().get(childIndex).getChildList().get(0).
                                    getSubChildList().get(0).getSubChildItem().size();
                            for(int i=0;i<SubChildItemSize;i++){
                                String StuAnswer = bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                        get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
                                String ItemAnswer = bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                        get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
                                int SortIndex = bkfxPaperEntity.getQuesList().get(childIndex).getChildList().get(0).
                                        getSubChildList().get(0).getSubChildItem().get(i).getSortIndex();

                                if(SubmitState==2){

                                    if (ItemAnswer.equals(StuAnswer)) {
                                        mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex + "','" +
                                                "<font color=\"#00b30d\">" + SortIndex +"." + StuAnswer + "</font>')");
                                    } else {
                                        mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex + "','" +
                                                "<font color=\"#ff0000\">" + SortIndex + "." + StuAnswer + "</font>"+
                                                "<font color=\"#00b30d\">("+ItemAnswer+")"+"</font>"+"')");
                                    }
                                }else {
                                    if(clickWhichIndex==SortIndex){
                                        mWvQuesBody.loadUrl("javascript:setBackGroundColor('" + "blank" + SortIndex +
                                                "','" + "#326DE9" + "')");
                                        if (StuAnswer.equals("")) {
                                            mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex +
                                                    "','" + "<font color=\"#ffffff\">" + SortIndex + "</font>')");
                                        } else {
                                            mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex +
                                                    "','" + "<font color=\"#ffffff\">" + SortIndex + "." + StuAnswer + "</font>')");
                                        }
                                    }else{
                                        mWvQuesBody.loadUrl("javascript:setBackGroundColor('" + "blank" + SortIndex +
                                                "','" + "#00000000" + "')");
                                        if (StuAnswer.equals("")) {
                                            mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex +
                                                    "','" + "<font color=\"#326DE9\">" + SortIndex + "</font>')");
                                        } else {
                                            mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex +
                                                    "','" + "<font color=\"#326DE9\">" + SortIndex + "." + StuAnswer + "</font>')");
                                        }
                                    }

                                }
                            }
                        }
                    });
                    mH1.removeCallbacks(this);
            }
        },500);
        /****************************************************************************************/
    }

    private int clickWhichIndex = -1;
    @SuppressWarnings("unused")
    private final class JSInterface{

        @JavascriptInterface
        public void clickFunction(final int position) {
            //在webview中进行点击选择需要作答的区间
            getActivity().runOnUiThread(new Runnable() {
                @SuppressLint("NewApi")
                @Override
                public void run() {
                    Log.e("LOGTAG", "===========JSInterface============" + String.valueOf(position));
                    clickWhichIndex = position;

                    mWvQuesBody.evaluateJavascript("javascript:scrollTop('"+"blank"+clickWhichIndex+"')", new ValueCallback<String>() {
                        @Override
                        public void onReceiveValue(String value) {
                           writeStuAnswer();
                        }
                    });

                }
            });
        }

    }

    private void showMakDialog(List<Boolean> answerResult){
        //显示底部答题卡弹窗
        final ButtomResultAnswerSheetDialog mMaskDialog
                = new ButtomResultAnswerSheetDialog(getActivity(),answerResult.size(),answerResult,false,false);
        mMaskDialog.show();

        boolean isThisQuesPass = false;
        for(int i =0;i<answerResult.size();i++){
            isThisQuesPass = answerResult.get(i);
            if(!isThisQuesPass){
                break;
            }
        }

        final Handler mH = new Handler();
        final boolean finalIsThisQuesPass = isThisQuesPass;
        mH.postDelayed(new Runnable() {
            @Override
            public void run() {
                mMaskDialog.dismiss();
                if(finalIsThisQuesPass) {
                    callBackFragmentPpt.pageMoveNext();
                }else{
                    Toast.makeText(getActivity(),"当前题目作答有误",Toast.LENGTH_SHORT).show();
                }
                mH.removeCallbacks(this);
            }
        }, 1900);

    }

//    private void showAnswerView(){
//        if(mVpAnswer.getVisibility()==View.GONE) {
//            ObjectAnimator translationY = ObjectAnimator.ofFloat(mVpAnswer, View.TRANSLATION_Y, 300f, 0f);
//            AnimatorSet setShow = new AnimatorSet();
//            setShow.playTogether(translationY);
//            setShow.setDuration(300);
//            setShow.addListener(new Animator.AnimatorListener() {
//                @Override
//                public void onAnimationStart(Animator animation) {
//                    mVpAnswer.setVisibility(View.VISIBLE);
//                }
//
//                @Override
//                public void onAnimationEnd(Animator animation) {
//
//                }
//
//                @Override
//                public void onAnimationCancel(Animator animation) {
//
//                }
//
//                @Override
//                public void onAnimationRepeat(Animator animation) {
//
//                }
//            });
//            setShow.start();
//        }
//    }
//    private void hideAnswerView(){
//        if(mVpAnswer.getVisibility()==View.VISIBLE) {
//            ObjectAnimator translationY = ObjectAnimator.ofFloat(mVpAnswer, View.TRANSLATION_Y, 0f, 300f);
//            AnimatorSet setShow = new AnimatorSet();
//            setShow.playTogether(translationY);
//            setShow.setDuration(300);
//            setShow.addListener(new Animator.AnimatorListener() {
//                @Override
//                public void onAnimationStart(Animator animation) {
//
//                }
//
//                @Override
//                public void onAnimationEnd(Animator animation) {
//                    mVpAnswer.setVisibility(View.GONE);
//                }
//
//                @Override
//                public void onAnimationCancel(Animator animation) {
//
//                }
//
//                @Override
//                public void onAnimationRepeat(Animator animation) {
//
//                }
//            });
//            setShow.start();
//        }
//    }

    private void showRecordMiView(){
        if(mRlMyRecordBg.getVisibility()==View.GONE) {
            ObjectAnimator translationY = ObjectAnimator.ofFloat(mRlMyRecordBg, View.TRANSLATION_Y, 300f, 0f);
            AnimatorSet setShow = new AnimatorSet();
            setShow.playTogether(translationY);
            setShow.setDuration(300);
            setShow.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animation) {
                    mRlMyRecordBg.setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationEnd(Animator animation) {

                }

                @Override
                public void onAnimationCancel(Animator animation) {

                }

                @Override
                public void onAnimationRepeat(Animator animation) {

                }
            });
            setShow.start();
        }
    }
    private void hideRecordMiView(){
        if(mRlMyRecordBg.getVisibility()==View.VISIBLE) {
            ObjectAnimator translationY = ObjectAnimator.ofFloat(mRlMyRecordBg, View.TRANSLATION_Y, 0f, 300f);
            AnimatorSet setShow = new AnimatorSet();
            setShow.playTogether(translationY);
            setShow.setDuration(300);
            setShow.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animation) {

                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    mRlMyRecordBg.setVisibility(View.GONE);
                }

                @Override
                public void onAnimationCancel(Animator animation) {

                }

                @Override
                public void onAnimationRepeat(Animator animation) {

                }
            });
            setShow.start();
        }
    }

    public void setUserVisibleHint(boolean isVisibleToUser) {

        if(isVisibleToUser) {
            final Handler mH1 = new Handler();
            mH1.postDelayed(new Runnable() {
                @SuppressLint("NewApi")
                @Override
                public void run() {
                    if(mVpAnswer!=null) {
                        writeStuAnswer();
                        mH1.removeCallbacks(this);
                    }else{
                        mH1.post(this);
                    }
                }
            },1000);
        }

        if(isVisibleToUser){
            Handler mH = new Handler();
            mH.postDelayed(new Runnable() {
                @Override
                public void run() {
                    int SubmitState = bkfxPaperEntity.getPaperAnswer().get(childIndex).getSubmitState();
                    if (SubmitState != 2) {
                        showRecordMiView();
                        mRecoderUtils = new AudioRecoderUtils();
                        SkEgnManager.getInstance(getActivity()).startRecord(mCoreType, "", QType.QTYPE_EMPTY, mOnRecordListener);
                        mRecoderUtils.startRecord();
                    }else{
                        mRlMyRecordBg.setVisibility(View.GONE);
                        SkEgnManager.getInstance(getActivity()).stopRecord();
                        if(mRecoderUtils!=null) {
                            mRecoderUtils.stopRecord();
                        }
                    }
                }
            },300);

        }else{
            if(mRlMyRecordBg!=null) {
                mRlMyRecordBg.setVisibility(View.GONE);
                SkEgnManager.getInstance(getActivity()).stopRecord();
                if(mRecoderUtils!=null) {
                    mRecoderUtils.stopRecord();
                }
            }
        }
    }
    /****************************************************************************/
    private AudioRecoderUtils mRecoderUtils;
    private String  mCoreType = CoreType.EN_ASR_REC;
    /*
     * 话咪录音操作
     * */
    OnRecordListener mOnRecordListener = new OnRecordListener() {
        @Override
        public void onRecordStart() {
            //开始录制
            Log.e("==onRecordingAA==","========vad_status==========="+"121212121212");
        }
        @Override
        public void onRecording(int vad_status, int sound_intensity) {
            //录制中
            int SubmitState = bkfxPaperEntity.getPaperAnswer().get(childIndex).getSubmitState();
            if(SubmitState==2){
                mIsExitTranslate = true;
                SkEgnManager.getInstance(getActivity()).stopRecord();
                mRecoderUtils.stopRecord();
            }
            Log.e("==onRecordingAA==","========vad_status==========="+vad_status);
            Log.e("==onRecordingBB==","=========sound_intensity==========="+sound_intensity);
            showRecordVolumeSize(sound_intensity);
            if(vad_status==2){
                SkEgnManager.getInstance(getActivity()).stopRecord();
                mRecoderUtils.stopRecord();
            }
        }
        @Override
        public void onRecordEnd(String result) {
            //录制结束
            try {
                final JSONObject json = new JSONObject(result);
                Log.e("17kouyuAAA", "返回json===>" + result);
                String choiceResult = "";
                if(!getResult(result).equals("")) {
                    choiceResult = getResult(result);
                }
                Log.e("==AFGAFG==","========KKKKK》》==========="+choiceResult);
                int OptionSize = bkfxPaperEntity.getQuesList().get(childIndex).getChildList().//获取小题对应的选项个数
                        get(0).getSubChildList().get(0).getOptionList().size();
                int SortIndexFirst = bkfxPaperEntity.getQuesList().get(childIndex).getChildList().get(0).
                        getSubChildList().get(0).getSubChildItem().get(0).getSortIndex();

                if(choiceResult.equals("a")||choiceResult.equals("hey")||
                        choiceResult.equals("b")||  choiceResult.equals("boy")||
                        choiceResult.equals("c")||
                        choiceResult.equals("d")||choiceResult.equals("dog")||
                        choiceResult.equals("e")||
                        choiceResult.equals("f")||
                        choiceResult.equals("g")||
                        choiceResult.equals("h")||
                        choiceResult.equals("i")||
                        choiceResult.equals("j")||
                        choiceResult.equals("k")){

                    if(choiceResult.equals("a")||choiceResult.equals("hey")){
                        if(OptionSize>=1) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("A");
                        }
                    }else if(choiceResult.equals("b")||  choiceResult.equals("boy")){
                        if(OptionSize>=2) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("B");
                        }
                    }else if(choiceResult.equals("c")){
                        if(OptionSize>=3) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("C");
                        }
                    }else if( choiceResult.equals("d")||choiceResult.equals("dog")){
                        if(OptionSize>=4) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("D");
                        }
                    }else if( choiceResult.equals("e")){
                        if(OptionSize>=5) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("E");
                        }
                    }else if( choiceResult.equals("f")){
                        if(OptionSize>=6) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("F");
                        }
                    }else if( choiceResult.equals("g")){
                        if(OptionSize>=7) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("G");
                        }
                    }else if( choiceResult.equals("h")){
                        if(OptionSize>=8) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("H");
                        }
                    }else if( choiceResult.equals("i")){
                        if(OptionSize>=9) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("I");
                        }
                    }else if( choiceResult.equals("j")){
                        if(OptionSize>=9) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("J");
                        }
                    }else if( choiceResult.equals("k")){
                        if(OptionSize>=9) {
                            bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(clickWhichIndex-SortIndexFirst).setStuAnswer("K");
                        }
                    }
                    refreshRecordAnswer();
                }else{
                    if(!mIsExitTranslate) {
                        SkEgnManager.getInstance(getActivity()).startRecord(mCoreType, "", QType.QTYPE_EMPTY, mOnRecordListener);
                        mRecoderUtils.startRecord();
                    }
                }


            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    };

    private void refreshRecordAnswer(){

        int AnsweredCount=0;
        int AnsweredCountTrue=0;
        int ChildListSize = bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                get(0).getSubChildList().get(0).getSubChildItem().size();
        Log.e("==AXC===","==================小题个数=====wwww=========="+ChildListSize);
        for(int i=0;i<ChildListSize;i++){
            String StuAnswer =  bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                    get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
            if(!StuAnswer.equals("")){
                AnsweredCount = AnsweredCount+1;
            }

            String ItemAnswer =  bkfxPaperEntity.getQuesList().get(childIndex).getChildList().
                    get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
            if(ItemAnswer.equals(StuAnswer)){
                AnsweredCountTrue = AnsweredCountTrue+1;
            }
            Log.e("==AXC===","==================完成个数=====wwww=========="+AnsweredCount);
        }
        //若作答完成则显示答案，记录作答状态，否则亦然
        if (AnsweredCount == ChildListSize) {
            bkfxPaperEntity.getPaperAnswer().get(childIndex).setSubmitState(2);
            hideRecordMiView();

            double EachScore = 0;
            String QuesList_QuesID = bkfxPaperEntity.getQuesList().get(childIndex).getQuesID();
            int PaperQuesSize = bkfxPaperEntity.getPaperQues().size();
            for(int i=0;i<PaperQuesSize;i++){
                int PaperQues_QuesListSize = bkfxPaperEntity.getPaperQues().get(childIndex).getQuesList().size();
                for(int j=0;j<PaperQues_QuesListSize;j++){
                    String PaperQues_QuesID = bkfxPaperEntity.getPaperQues().get(childIndex).getQuesList().get(j).getQuesID();
                    if(QuesList_QuesID.equals(PaperQues_QuesID)){
                        EachScore = bkfxPaperEntity.getPaperQues().get(childIndex).getEachScore();
                        break;
                    }
                }
            }
            double ResultStuScore = AnsweredCountTrue*EachScore;
            showResultStuScore(ResultStuScore);
        }else{
            bkfxPaperEntity.getPaperAnswer().get(childIndex).setSubmitState(1);
        }
        Log.e("==mAdapter===","=======此处刷新AnswerAdapter============"+"不知道");

        list.clear();
        int totalItemCountA = bkfxPaperEntity.getQuesList().get(childIndex).getChildList().size();
        for(int i=0;i<totalItemCountA;i++) {
            final RecyclerView mRvAnswer = new RecyclerView(getActivity());
            mRvAnswer.setLayoutManager(new LinearLayoutManager(getActivity()));//必须先设置LayoutManager
            BkfxPptAnswerAdapter mAnswerAdapter = new BkfxPptAnswerAdapter(getActivity(),
                    bkfxPaperEntity,childIndex,new BkfxPptAnswerAdapter.CallBackAdapterPpt() {

                @Override
                public void callHideRecordMiView() {

                }

                @Override
                public void callClickWhichIndex(String stuAnswer) {

                }

                @Override
                public void callShowResultStuScore(double stuScore) {

                }

                @Override
                public void callSetCurrentStuAnswer(String currentStuAnswer) {

                }
            });
            mRvAnswer.setAdapter(mAnswerAdapter);
            list.add(mRvAnswer);
        }
        mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));
        writeStuAnswer();

        //更新完后重新开启录音语音识别
        int SubmitState = bkfxPaperEntity.getPaperAnswer().get(childIndex).getSubmitState();
        if(SubmitState==2){
            SkEgnManager.getInstance(getActivity()).stopRecord();
            mRecoderUtils.stopRecord();
//            SaveItemQuesAnswer(childIndex);
        }else {
            SkEgnManager.getInstance(getActivity()).startRecord(mCoreType, "", QType.QTYPE_EMPTY, mOnRecordListener);
            mRecoderUtils.startRecord();
        }
    }

    private String getResult(String result) {

        String choiceSoundResult = "";
        StringBuilder keyValue = new StringBuilder();
        try{
            JSONObject returnObj = new JSONObject(result);
            JSONObject resultJSONObject = returnObj.getJSONObject("result");
            if(resultJSONObject.has("overall")){
                keyValue.append("总    分: " + resultJSONObject.getString("overall") + "\n");
            }
            Log.e("getResultAAAAA", "====返回json========答案=========>" + resultJSONObject.getString("recognition"));
            choiceSoundResult = resultJSONObject.getString("recognition");
//            notifyDataSetChanged();

        }catch (Exception e){
            e.printStackTrace();
        }
        keyValue.append("\n");
        keyValue.append(JSONTool.stringToJSON(result));

        return choiceSoundResult;
    }
    /***************************************************************************/

    public interface CallBackFragmentPpt {
        void pageMoveNext();
    }

    private void showRecordVolumeSize(final int volumesize){
        new Thread(new Runnable() {
            @Override
            public void run() {
                Message msg =Message.obtain();
                msg.obj = volumesize;
                msg.what = 1;
                handler.sendMessage(msg);

                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).start();

    }

    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case 1:
                    int VolumeSize = Integer.valueOf(msg.obj.toString());
                    if(VolumeSize>50){
                        VolumeSize=50;
                    }
                    int LevelSize = VolumeSize*200;
                    drawableMi.setLevel(LevelSize);
                    break;
            }
        }
    };


    //保存作答试题信息
//    private void SaveItemQuesAnswer(int position) {
//        List<ItemAnswerModel.ModelListBean> ModelList = new ArrayList<>();
//        int SubItemAnswerSize = -1;
//        String TypeNo = bkfxPaperEntity.getQuesList().get(position).getTypeInfo().getTypeNo();
//        List<ItemAnswerModel.ModelListBean.ChildListBean> ChildList = new ArrayList<>();
//
//        if(TypeNo.equals("N")||TypeNo.equals("Q")||
//                TypeNo.equals("b")||TypeNo.equals("U")||TypeNo.equals("S")||TypeNo.equals("m")){
//            List<ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItemList = new ArrayList<>();
//            SubItemAnswerSize = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).
//                    getSubChildList().get(0).getSubChildItem().size();
//            for(int i=0;i<SubItemAnswerSize;i++){
//                /*****SubChildItem*****************************************************************************/
//                String AudioPath = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).
//                        getSubChildList().get(0).getSubChildItem().get(i).getAudioPath();
//                String ImagePath = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).
//                        getSubChildList().get(0).getSubChildItem().get(i).getImagePath();
//                String ItemAnswer = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).
//                        getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
//                String StuAnswer = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).
//                        getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
//                int ItemIndex = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).
//                        getSubChildList().get(0).getSubChildItem().get(i).getItemIndex();
//
//                int ScoreRate = -1;
//                String[] ItemAnswerArray = LancooUtils.returnArray(ItemAnswer,"$/",2);
//                List<String> list=Arrays.asList(ItemAnswerArray);
//                if(list.contains(StuAnswer)){
//                    ScoreRate = 1;
//                }else{
//                    ScoreRate = 0;
//                }
//
//                ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean.SubChildItemBean subChildItemList
//                        = new ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean.SubChildItemBean();
//                subChildItemList.setAudioPath(AudioPath);
//                subChildItemList.setImagePath(ImagePath);
//                subChildItemList.setItemAnswer(ItemAnswer);
//                subChildItemList.setStuAnswer(StuAnswer);
//                subChildItemList.setItemIndex(ItemIndex);
//                subChildItemList.setScoreRate(ScoreRate);
//                /**********************************************************************************/
//                SubChildItemList.add(subChildItemList);
//
//            }
//            /****SubChildList******************************************************************************/
//            int SubChildIndex = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).getSubChildList().get(0).getSubChildIndex();
//
//            ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean subChildList =
//                    new ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean();
//            subChildList.setSubChildIndex(SubChildIndex);
//            subChildList.setSubChildItem(SubChildItemList);
//            /**********************************************************************************/
//
//            /****ChildList******************************************************************************/
//            List<ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
//            int ChildIndex = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).getChildIndex();
//            SubChildList.add(subChildList);
//
//            ItemAnswerModel.ModelListBean.ChildListBean childList = new ItemAnswerModel.ModelListBean.ChildListBean();
//            childList.setChildIndex(ChildIndex);
//            childList.setSubChildList(SubChildList);
//            ChildList.add(childList);
//            /**********************************************************************************/
//
//            /****modelList******************************************************************************/
//            float CorrectRate = 0;//需要计算小题准确率，这里先模拟为0
//            int AnswerTrue = 0;
//            int SubChildListSize = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).
//                    getSubChildList().get(0).getSubChildItem().size();
//            for(int k=0;k<SubChildListSize;k++){
//                String ItemAnswerK = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).
//                        getSubChildList().get(0).getSubChildItem().get(k).getItemAnswer();
//                String StuAnswerK = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(0).
//                        getSubChildList().get(0).getSubChildItem().get(k).getStuAnswer();
//
//                String[] ItemAnswerArray = LancooUtils.returnArray(ItemAnswerK,"$/",2);
//                List<String> list=Arrays.asList(ItemAnswerArray);
//                if(list.contains(StuAnswerK)){
//                    AnswerTrue = AnswerTrue+1;
//                }
//            }
//            CorrectRate = LancooUtils.getCorrectRate(AnswerTrue,SubChildListSize);
//            int lastPaperDuration = bkfxPaperEntity.getDuration();
//            int ItemDuration = Integer.valueOf(BkfxActivity.getChronometerSeconds(BkfxActivity.mChronometerAnswerTime))-lastPaperDuration;
//            String GenreID = bkfxPaperEntity.getQuesList().get(position).getGenreInfo().getGenreID();
//            String QuesID = bkfxPaperEntity.getQuesList().get(position).getQuesID();
//            String TyoeNo = bkfxPaperEntity.getQuesList().get(position).getTypeInfo().getTypeNo();
//
//            ItemAnswerModel.ModelListBean modelList = new ItemAnswerModel.ModelListBean();
//            modelList.setCorrectRate(CorrectRate);
//            modelList.setDuration(ItemDuration);
//            modelList.setGenreID(GenreID);
//            modelList.setQuesID(QuesID);
//            modelList.setTypeNo(TypeNo);
//            modelList.setChildList(ChildList);
//            /**********************************************************************************/
//            ModelList.add(modelList);
//        }else{
//
////            List<ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItemList = new ArrayList<>();
////            List<ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
//
//            SubItemAnswerSize = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().size();
//            for(int i=0;i<SubItemAnswerSize;i++){
//                List<ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItemList = new ArrayList<>();
//                /*****SubChildItem*****************************************************************************/
//                String AudioPath = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(i).
//                        getSubChildList().get(0).getSubChildItem().get(0).getAudioPath();
//                String ImagePath = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(i).
//                        getSubChildList().get(0).getSubChildItem().get(0).getImagePath();
//                String ItemAnswer = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(i).
//                        getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
//                String StuAnswer = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(i).
//                        getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
//                int ItemIndex = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(i).
//                        getSubChildList().get(0).getSubChildItem().get(0).getItemIndex();
////                double ScoreRate = bkfxPaperEntity.getPaperAnswer().get(savePosition).getChildList().get(i).
////                        getSubChildList().get(0).getSubChildItem().get(0).getScoreRate();
//                int ScoreRate = -1;
//                if(ItemAnswer.equals(StuAnswer)){
//                    ScoreRate = 1;
//                }else{
//                    ScoreRate = 0;
//                }
//
//                ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean.SubChildItemBean subChildItemList
//                        = new ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean.SubChildItemBean();
//                subChildItemList.setAudioPath(AudioPath);
//                subChildItemList.setImagePath(ImagePath);
//                subChildItemList.setItemAnswer(ItemAnswer);
//                subChildItemList.setStuAnswer(StuAnswer);
//                subChildItemList.setItemIndex(ItemIndex);
//                subChildItemList.setScoreRate(ScoreRate);
//                /**********************************************************************************/
//
//                /****SubChildList******************************************************************************/
//                int SubChildIndex = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(i).getSubChildList().get(0).getSubChildIndex();
//                SubChildItemList.add(subChildItemList);
//
//                ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean subChildList =
//                        new ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean();
//                subChildList.setSubChildIndex(SubChildIndex);
//                subChildList.setSubChildItem(SubChildItemList);
//                /**********************************************************************************/
//
//                /****ChildList******************************************************************************/
//                List<ItemAnswerModel.ModelListBean.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
//                int ChildIndex = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(i).getChildIndex();
//                SubChildList.add(subChildList);
//
//                ItemAnswerModel.ModelListBean.ChildListBean childList = new ItemAnswerModel.ModelListBean.ChildListBean();
//                childList.setChildIndex(ChildIndex);
//                childList.setSubChildList(SubChildList);
//                ChildList.add(childList);
//                /**********************************************************************************/
//            }
//
//            /****modelList******************************************************************************/
//            float CorrectRate = 0;//需要计算小题准确率，这里先模拟为0
//            int AnswerTrue = 0;
//            int ChildListSize = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().size();
//            for(int k=0;k<ChildListSize;k++){
//                String ItemAnswerK = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(k).
//                        getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
//                String StuAnswerK = bkfxPaperEntity.getPaperAnswer().get(position).getChildList().get(k).
//                        getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
////                if(ItemAnswerK.equals(StuAnswerK)){
////                    AnswerTrue = AnswerTrue+1;
////                }
//                String[] ItemAnswerArray = LancooUtils.returnArray(ItemAnswerK,"$/",2);
//                List<String> list=Arrays.asList(ItemAnswerArray);
//                if(list.contains(StuAnswerK)){
//                    AnswerTrue = AnswerTrue+1;
//                }
//            }
//            CorrectRate = LancooUtils.getCorrectRate(AnswerTrue,ChildListSize);
//            int lastPaperDuration = bkfxPaperEntity.getDuration();
//            int ItemDuration = Integer.valueOf(BkfxActivity.getChronometerSeconds(BkfxActivity.mChronometerAnswerTime))-lastPaperDuration;
//            String GenreID = bkfxPaperEntity.getQuesList().get(position).getGenreInfo().getGenreID();
//            String QuesID = bkfxPaperEntity.getQuesList().get(position).getQuesID();
//            String TyoeNo = bkfxPaperEntity.getQuesList().get(position).getTypeInfo().getTypeNo();
//
//            ItemAnswerModel.ModelListBean modelList = new ItemAnswerModel.ModelListBean();
//            modelList.setCorrectRate(CorrectRate);
//            modelList.setDuration(ItemDuration);
//            modelList.setGenreID(GenreID);
//            modelList.setQuesID(QuesID);
//            modelList.setTypeNo(TypeNo);
//            modelList.setChildList(ChildList);
//            /**********************************************************************************/
//            ModelList.add(modelList);
//        }
//
//        ItemAnswerModel itemAnswerModel =new ItemAnswerModel();
//        itemAnswerModel.setSubjectID(UserInfoBean.SubjectID);
//        itemAnswerModel.setCourseClassID(UserInfoBean.CourseClassID);
//        itemAnswerModel.setPaperID(bkfxPaperEntity.getPaperID());
//        int PaperDuration = Integer.valueOf(BkfxActivity.getChronometerSeconds(BkfxActivity.mChronometerAnswerTime));
//        itemAnswerModel.setPaperDuration(PaperDuration);
//        itemAnswerModel.setGlobalGrade(UserInfoBean.GlobalGrade);
//        itemAnswerModel.setStuID(UserInfoBean.StuId);
//        itemAnswerModel.setSchoolID(UserInfoBean.SchoolID);
//        itemAnswerModel.setModelList(ModelList);
//        itemAnswerModel.setKey(UserInfoBean.Key);
//
//        Gson gson=new Gson();
//        String BODY= gson.toJson(itemAnswerModel);
//        Log.e("==BODYAA=","========BODY====请求参数=====AAAAA=============="+BODY);
//        String BASE_URL = URLConstant.BASE_URL;
//        Retrofit retrofit=new Retrofit.Builder()
//                .baseUrl(BASE_URL)
//                .addConverterFactory( GsonConverterFactory.create())
//                .build();
//        PostSaveItemQuesAnswer_interface postRequest = retrofit.create(PostSaveItemQuesAnswer_interface.class);
//        RequestBody body=RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),BODY);
//        Call<String> call = postRequest.saveItemQuesAnswer(body);
//        call.enqueue(new Callback<String>() {
//            @Override
//            public void onResponse(Call<String> call, Response<String> response) {
//                Log.e("onResponse=","===============成功============="+response.body().toString());
////                String result = response.body().toString();
//            }
//
//            @Override
//            public void onFailure(Call<String> call, Throwable t) {
//                Log.e("onFailure", t.getMessage());
//            }
//        });
//
//    }

    private void writeStuAnswer(){
        Log.e("LOGTAG", "===========onReceiveValue value=============" + clickWhichIndex);
        int SubmitState = bkfxPaperEntity.getPaperAnswer().get(childIndex).getSubmitState();
        int SubChildItemSize = bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().get(0).
                getSubChildList().get(0).getSubChildItem().size();
        for(int j=0;j<SubChildItemSize;j++) {
            String StuAnswer = bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                    get(0).getSubChildList().get(0).getSubChildItem().get(j).getStuAnswer();
            String ItemAnswer = bkfxPaperEntity.getPaperAnswer().get(childIndex).getChildList().
                    get(0).getSubChildList().get(0).getSubChildItem().get(j).getItemAnswer();
            int SortIndex = bkfxPaperEntity.getQuesList().get(childIndex).getChildList().
                    get(0).getSubChildList().get(0).getSubChildItem().get(j).getSortIndex();

            if(clickWhichIndex==SortIndex) {

                mWvQuesBody.loadUrl("javascript:setBackGroundColor('" + "blank" + clickWhichIndex +
                        "','" + "#326DE9" + "')");

                if(SubmitState==2){
                    if (ItemAnswer.equals(StuAnswer)) {
                        mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex + "','" +
                                "<font color=\"#00b30d\">" + SortIndex +"." + StuAnswer + "</font>')");
                    } else {
                        mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex + "','" +
                                "<font color=\"#ff0000\">" + SortIndex + "." + StuAnswer + "</font>"+
                                "<font color=\"#00b30d\">("+ItemAnswer+")"+"</font>"+"')");
                    }
                }else {
                    if (StuAnswer.equals("")) {
                        mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex +
                                "','" + "<font color=\"#ffffff\">" + SortIndex + "</font>')");
                    } else {
                        mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex +
                                "','" + "<font color=\"#ffffff\">" + SortIndex + "." + StuAnswer + "</font>')");
                    }
                }

            }else{

                mWvQuesBody.loadUrl("javascript:setBackGroundColor('" + "blank" + SortIndex +
                        "','" + "#00000000" + "')");

                if(SubmitState==2){
                    if (ItemAnswer.equals(StuAnswer)) {
                        mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex + "','" +
                                "<font color=\"#00b30d\">" + SortIndex +"." + StuAnswer + "</font>')");
                    } else {
                        mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex + "','" +
                                "<font color=\"#ff0000\">" + SortIndex + "." + StuAnswer + "</font>"+
                                "<font color=\"#00b30d\">("+ItemAnswer+")"+"</font>"+"')");
                    }
                }else {
                    mWvQuesBody.loadUrl("javascript:setBackGroundColor('" + "blank" + SortIndex +
                            "','" + "#00000000" + "')");
                    if (StuAnswer.equals("")) {
                        mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex +
                                "','" + "<font color=\"#326DE9\">" + SortIndex + "</font>')");
                    } else {
                        mWvQuesBody.loadUrl("javascript:CalledByJavaCodeWithPara('" + "blank" + SortIndex +
                                "','" + "<font color=\"#326DE9\">" + SortIndex + "." + StuAnswer + "</font>')");
                    }
                }
            }

        }
    }

    private void showResultStuScore(double stuScore){

        String strStuScore = String.valueOf(stuScore);
        if (strStuScore.contains("."))
        {
            String [] newStuScore = strStuScore.split("\\.");
            String front_stuScore = newStuScore[0];
            if(Integer.valueOf(front_stuScore)>=0 && Integer.valueOf(front_stuScore)<=9){
                drawStuScore(front_stuScore);
            }else{
                String str_front_stuScore_0 = front_stuScore.substring(0,1);
                drawStuScore(str_front_stuScore_0);
                String str_front_stuScore_1 = front_stuScore.substring(1,2);
                drawStuScore(str_front_stuScore_1);
            }
            String after_stuScore = newStuScore[1];
            if(Integer.valueOf(after_stuScore)>0){
                ImageView mIv_point = new ImageView(getActivity());
                mIv_point.setImageResource(R.mipmap.stu_score_point);
                mLlResultStuScore.addView(mIv_point);

                ImageView mIv_5 = new ImageView(getActivity());
                mIv_5.setImageResource(R.mipmap.stu_score_5);
                mLlResultStuScore.addView(mIv_5);

            }
        }

        ObjectAnimator translationXShow =  ObjectAnimator.ofFloat(mLlResultStuScore,View.TRANSLATION_X,500f,0f);
        ObjectAnimator alphaShow =  ObjectAnimator.ofFloat(mLlResultStuScore,View.ALPHA,0.6f,1.0f);
        AnimatorSet setShow = new AnimatorSet();
        setShow.playTogether(translationXShow,alphaShow);
        setShow.setInterpolator(new DecelerateInterpolator());
        setShow.setDuration(1600);
        setShow.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
                mLlResultStuScore.setVisibility(View.VISIBLE);
                BkfxActivity.mVpBkfx.setScrollble(false);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mLlResultStuScore.setVisibility(View.GONE);
                callBackFragmentPpt.pageMoveNext();
                BkfxActivity.mVpBkfx.setScrollble(true);
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
        setShow.start();

        Log.e("showResultStuScore","=======tlxz=========stuScore==============="+stuScore);

    }

    private void drawStuScore(String score){
        if(score.equals("0")){
            ImageView mIv_0 = new ImageView(getActivity());
            mIv_0.setImageResource(R.mipmap.stu_score_0);
            mLlResultStuScore.addView(mIv_0);
        }else if(score.equals("1")){
            ImageView mIv_1 = new ImageView(getActivity());
            mIv_1.setImageResource(R.mipmap.stu_score_1);
            mLlResultStuScore.addView(mIv_1);
        }else if(score.equals("2")){
            ImageView mIv_2 = new ImageView(getActivity());
            mIv_2.setImageResource(R.mipmap.stu_score_2);
            mLlResultStuScore.addView(mIv_2);
        }else if(score.equals("3")){
            ImageView mIv_3 = new ImageView(getActivity());
            mIv_3.setImageResource(R.mipmap.stu_score_3);
            mLlResultStuScore.addView(mIv_3);
        }else if(score.equals("4")){
            ImageView mIv_4 = new ImageView(getActivity());
            mIv_4.setImageResource(R.mipmap.stu_score_4);
            mLlResultStuScore.addView(mIv_4);
        }else if(score.equals("5")){
            ImageView mIv_5 = new ImageView(getActivity());
            mIv_5.setImageResource(R.mipmap.stu_score_5);
            mLlResultStuScore.addView(mIv_5);
        }else if(score.equals("6")){
            ImageView mIv_6 = new ImageView(getActivity());
            mIv_6.setImageResource(R.mipmap.stu_score_6);
            mLlResultStuScore.addView(mIv_6);
        }else if(score.equals("7")){
            ImageView mIv_7 = new ImageView(getActivity());
            mIv_7.setImageResource(R.mipmap.stu_score_7);
            mLlResultStuScore.addView(mIv_7);
        }else if(score.equals("8")){
            ImageView mIv_8 = new ImageView(getActivity());
            mIv_8.setImageResource(R.mipmap.stu_score_8);
            mLlResultStuScore.addView(mIv_8);
        }else if(score.equals("9")){
            ImageView mIv_9 = new ImageView(getActivity());
            mIv_9.setImageResource(R.mipmap.stu_score_9);
            mLlResultStuScore.addView(mIv_9);
        }
    }

    private boolean mIsExitTranslate = false;
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.e("onDestroy","=====fragment=======退出备考复习========mmmm======"+childIndex);
        if(mRecoderUtils!=null) {
            SkEgnManager.getInstance(getActivity()).stopRecord();
            mRecoderUtils.stopRecord();
            mIsExitTranslate = true;
        }
    }

}
